package com.yang.webapi.module.controller;

import com.yang.service.model.vo.ScarVO;
import com.yang.webapi.module.service.ScarWebService;
import com.zhy.base.webapi.annoation.ResponseFormatter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by baipan
 * Date: 2019/12/26 0026
 */
@RestController
@ResponseFormatter
@RequestMapping(value = "scar")
@CrossOrigin
@Slf4j
@Api(tags = "购物车管理", description = "ScarController")
public class ScarController {
    @Autowired
    private ScarWebService scarWebService;

    @ApiOperation("获取用户所有的购物车")
    @GetMapping("list")
    public List<ScarVO> getAllScar(){
        return scarWebService.getAllScar();
    }

    @ApiOperation("添加购物车")
    @PostMapping("")
    public boolean addScar(@RequestParam(value = "productId") String productId){
        return scarWebService.addScar(productId);
    }
    @ApiOperation("批量删除订单")
    @DeleteMapping("delete/batch")
    public boolean deleteBatch(@RequestParam(value = "scarList") List<String> scarList){
        return scarWebService.deleteBatch(scarList);
    }
}
